package addon.w3.mdx.com;

import java.io.IOException;

import addon.w3.mdx.MDXCOM;
import addon.w3.mdx.LEDataInputStream;
import addon.w3.mdx.MDXException;
import addon.w3.mdx.MDXParentCOM;

/**
 * KMTA						// [Alpha]
	long	nunks;
	long	LineType;			(0:don't interp;1:linear;2:hermite;3:bezier)
	long	GlobalSeqId;			// 0xFFFFFFFF if none
	struct {
		long	Frame;
		float	State;			(0 or 1)
		if (LineType > 1) {
			float	InTan;
			float	OutTan;
		}
	} alpha[nunks];
KATV	// [Visibility]:  KMTA;
KLAV	// [Visibility]:  KMTA;
KP2V	// [Visibility]:  KMTA;
KPEV	// [Visibility]:  KMTA;
KRVS	// [Visibility]:  KMTA;
KGAO	// [Alpha]:	  KMTA;
KLAI	// [Intensity]:   KMTA;
KLBI	// [AmbIntensity]:KMTA;
KMTF	// [TextureID]:	  KMTA; -> state is long value not float
KP2E	// [EmissnRate]:  KMTA;
KP2L	// [Latitude]: 	  KMTA;
KP2N	// [Length]: 	  KMTA;
KP2S	// [Speed]:	  KMTA;
KP2W	// [Width]: 	  KMTA;
KRHA	// [HeightAbove]: KMTA;
KRHB	// [HeightBelow]: KMTA;
KCRL 	// [Rotation]:	  KMTA;
 * @author madjk
 *
 */
public class MDXAlpha extends MDXParentCOM {
	String tag = "KMTA";
	String subTag = "KMTA:Alpha";
	public int nunks = -1;
	public int lineType = -1;
	public int globalSeqID = -1;
		
	MDXAlphaCOM mdcoms[] = null;
	
	public MDXAlpha() {
	}
	
	public MDXAlpha(String tag, String subTag) {
		this.tag = tag;
	}
	
	public String getTag() {
		return tag;
	}
	
	public void _decode(LEDataInputStream ins) throws IOException, MDXException {
		nunks = ins.readInt();
		lineType = ins.readInt();
		globalSeqID = ins.readInt();
		mdcoms = new MDXAlphaCOM[nunks];
		for (int i = 0; i < mdcoms.length; i++) {
			mdcoms[i] = new MDXAlphaCOM(subTag,lineType);
			mdcoms[i].decode(ins);
		}
	}
		
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("TAG : "+getTag());
		sb.append("\n\tNUNKS : "+nunks);
		sb.append("\n\tLINETYPE : "+lineType);
		sb.append("\n\tGLOBALSEQID : "+globalSeqID);
		if(mdcoms != null && mdcoms.length > 0) sb.append("\n\tALPHA[] : "+mdcoms.length);
		return sb.toString();
	}

	@Override
	public boolean isImplicitTag() {
		return true;
	}
}